package com.wenhai.spring.aop.pointcut;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.NameMatchMethodPointcutAdvisor;

/**
 * {@link org.springframework.aop.support.NameMatchMethodPointcutAdvisor}
 *
 * @author wenhai
 * @date   2021/5/6
 * @see org.springframework.aop.support.NameMatchMethodPointcutAdvisor
 */
public class NamePointcutUsingAdvisor {
    public static void main(String[] args) {
        GrammyGuitarist target = new GrammyGuitarist();
        NameMatchMethodPointcutAdvisor advisor = new NameMatchMethodPointcutAdvisor(new SimpleAdvice());
        advisor.addMethodName("sing").addMethodName("rest");
        ProxyFactory pf = new ProxyFactory();
        pf.setTarget(target);
        pf.addAdvisor(advisor);
        GrammyGuitarist proxy = (GrammyGuitarist) pf.getProxy();
        proxy.talk();
        proxy.sing(new Guitar());

    }
}
